




$("#submit").click(function(){

	var number = $("#number").val();
	var password = $("#password").val();

    if (number == '' || password == '') {
        alert("你尚未填写完整信息，请检查重新填写");
    }
    else{
    	var data = {
		"user.UserNumber":number
		}
		UserAPI.searchUserAPI(data,
			function(json){
				if (json == "") {
					alert("用户不存在，请检查输入")
				}else{
					$.each(json,function(i,val){
						if ( password == val.userPasswd ) {
							sessionStorage.setItem('userNumber',val.userNumber);
							sessionStorage.setItem('userName',val.userName);
							var userIdObj = {
								"userRole.userId":val.userId
							}
							relateAPI.getUserRoleAPI(userIdObj,
								function(json){
									// switch()
									$.each(json,function(i,val){
										// if {};
										// alert(val.roleId);
										// switch(val.roleId){
										// 	case 1 : window.location.herf="../admin.html";break;
										// 	case 2 : window.location.herf="../manage.html"; break;
										// 	case 3 : window.location.herf="../index.html"; break;
										// };
										if (val.roleId == 1 ) {
											window.location.href="../admin.html";
										}
										else if (val.roleId == 2) {
											window.location.href = "../manage.html";
										}
										else if(val.roleId == 3){
											window.location.href = "../index.html";
										}
											;
									})
								},function(){
									alert("系统繁忙，请重试")
								})

						}
						else{
							alert("密码错误，请重新输入");
						};
					});
				}
				
			},function(){

			})
    }
})
